package com.itxh.core.builder;

import com.itxh.core.config.Configuration;
import org.dom4j.Element;

import java.util.List;

public class XMLMapperBuilder {
    private Configuration configuration;

    public XMLMapperBuilder(Configuration configuration) {
        this.configuration = configuration;
    }

    public void parseMapper(Element mapperElement) {
        String namespace = mapperElement.attributeValue("namespace");
        if (namespace == null || namespace.equals("")){
            return;
        }
        List<Element> selectElements = mapperElement.elements("select");
        for (Element selectElement : selectElements) {
            XMLStatementBuilder statementBuilder = new XMLStatementBuilder(configuration);
            statementBuilder.parseStatement(namespace,selectElement);
        }
        // 映射文件中，还有其他的标签需要解析，此处不写了
    }
}
